import 'package:richedit/data/image_group_entity.dart';
import 'package:richedit/data/image_entity.dart';

imageGroupEntityFromJson(ImageGroupEntity data, Map<String, dynamic> json) {
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['isHorizontal'] != null) {
		data.isHorizontal = json['isHorizontal'];
	}
	if (json['children'] != null) {
		data.children = (json['children'] as List).map((v) => ImageEntity().fromJson(v)).toList();
	}
	if (json['imgNum'] != null) {
		data.imgNum = json['imgNum'] is String
				? int.tryParse(json['imgNum'])
				: json['imgNum'].toInt();
	}
	return data;
}

Map<String, dynamic> imageGroupEntityToJson(ImageGroupEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['name'] = entity.name;
	data['isHorizontal'] = entity.isHorizontal;
	data['children'] =  entity.children?.map((v) => v.toJson())?.toList();
	data['imgNum'] = entity.imgNum;
	return data;
}